<!--
 * @details: 
 * @brief: 
 * @version: 1.0
 * @author: liuri
 * @Date: 2021-06-30 13:03:19
 * @LastEditors: liuri
 * @LastEditTime: 2021-06-30 13:12:27
 * @FilePath: /TestProject/htmlPath/javascript/md5_test.html
 * Copyright (C) 2021 liuri. All rights reserved.
-->
<!--
 * @Author: your name
 * @Date: 2021-06-05 14:03:27
 * @LastEditTime: 2021-06-29 15:23:44
 * @LastEditors: liuri
 * @Description: In User Settings Edit
 * @FilePath: /BeegoProject/code/MyBeeSite/views/adminlte/upload_file.html
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="order by dede58.com"/><title>后台管理系统</title>

<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script>
<script type="text/javascript" src="spark-md5.js"></script>
 <script type="text/javascript"> 
	
    
function submit1(file){
    var file = document.getElementById("addfile").files[0]
    file_md5=calculate1(file);
    console.info("computed hash11", file_md5);
}    
function calculate1(file){
{
    return 123455;
}
function calculate(file){
    var fileReader = new FileReader(),
        blobSlice = File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice,			
        chunkSize = 2097152,
        // 计算chunk的个数
        chunks = Math.ceil(file.size / chunkSize),
        currentChunk = 0,
        spark = new SparkMD5();

    fileReader.onload = function(e) {
        console.log("read chunk nr", currentChunk + 1, "of", chunks);
        spark.appendBinary(e.target.result); // append binary string
        currentChunk++;

        if (currentChunk < chunks) {
            loadNext();
        }
        else {
            console.log("finished loading");
            // 得到Hash 值 spark.end()					
            console.info("computed hash", spark.end()); // compute hash
            return spark.end()
        }
    };
    // 加载一下个chunk
    function loadNext() {
        var start = currentChunk * chunkSize,
            end = start + chunkSize >= file.size ? file.size : start + chunkSize;
        // 读取文件
        fileReader.readAsBinaryString(blobSlice.call(file, start, end));
    };

    loadNext();
}
</script>

</head>
<body class="modal white">


<!--     内容      -->
<div id="content" class="white">
	<div class="bloc">	
		<!-- <form id="uploadform" method="POST" enctype="multipart/form-data" >		 -->
			<!-- 文件选择 -->
			<div style="width: 100px;margin: 10px 10px 10px 10px;">
				<input id="addfile" name="addfile" type="file" /> 
			</div>		 
			<!-- 下拉框 -->
			<div style="width: 100px;margin: 10px 10px 10px 10px;">
				<select>
					<option value ="video">video</option>
					<option value ="text">text</option>
					<option value="pdf">pdf</option>
					<option value="work">work</option>
				</select>
			</div>
			<!-- 下拉框 -->
			<div style="width: 100px;margin: 10px 10px 10px 10px;">
				<select>
					<option value ="study">学习</option>
					<option value ="inspirational">励志</option>
					<option value="classic">经典</option>
					<option value="comedy">好笑</option>
					<option value="othesr">其他</option>
				</select>
			</div>
					
			<div class="input textarea">
				<label for="textarea1">描述</label>
				<textarea id="text_id" name="area2" style="width: 100%; height:120px;">
				</textarea>
			</div>
			<div class="submit">
				<input type="submit" id="sure" value="确定" onClick="submit1()">
			</div>
		<!-- </form> -->
	</div>
</div>
</body>
</html>